package com.spring.cloud.controller

import com.spring.cloud.module.UserInfo
import com.spring.cloud.service.HelloService
import com.spring.cloud.service.UserInfoService
import org.apache.logging.log4j.LogManager
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController

@RestController
class UserController {
    var logger = LogManager.getLogger(UserController::class)


    @Autowired
    lateinit var userInfoService :UserInfoService

    @Autowired
    lateinit var helloService :HelloService

    @GetMapping("/user/{userId}/id.json")
    @ResponseBody
    fun queryUserById(@PathVariable userId:Long): List<UserInfo> {
        return userInfoService.queryUserList(UserInfo(userId=userId,username = null,password = null))
    }


    @GetMapping("/getHello/{name}")
    @ResponseBody
    fun hello(@PathVariable name:String): String {
        logger.info("getHello ={}",name)
        return helloService.hello(name)
    }
}